package com.example.cicddemo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

@Controller
public class HomeController {

    @GetMapping("/")
    public String home(Model model) {
        model.addAttribute("serverTime", LocalDateTime.now());
        model.addAttribute("message", "欢迎使用CICD演示项目！");
        return "index";
    }
    
    @RestController
    @RequestMapping("/api")
    public static class ApiController {
        
        @GetMapping("/info")
        public Map<String, Object> getInfo() {
            Map<String, Object> info = new HashMap<>();
            info.put("name", "CICD演示项目");
            info.put("version", "1.0.0");
            info.put("timestamp", System.currentTimeMillis());
            return info;
        }
    }
}